﻿@namespace BootstrapBlazor.Components
@typeparam TValue
@inherits BootstrapInputBase<TValue>

@if (IsShowLabel)
{
    <BootstrapLabel required="@Required" for="@Id" ShowLabelTooltip="ShowLabelTooltip" Value="@DisplayText" />
}
<div class="@ClassString" @ref="AutoFillElement">
    <input @attributes="AdditionalAttributes" class="@ClassName" autocomplete="off" type="@Type" placeholder="@PlaceHolder" @bind-value="@InputString" @bind-value:event="oninput" @onblur="OnBlur" @onkeyup="OnKeyUp" @ref="FocusElement" />
    <i class="fa fa-fw fa-spinner fa-spin"></i>
    <div class="select-dropdown">
        <ul class="dropdown-list">
            @if (FilterItems.Any())
            {
                foreach (var item in FilterItems)
                {
                    <li class="dropdown-item" @onmousedown="e => OnClickItem(item)">
                        @if (Template != null)
                        {
                            @Template(item)
                        }
                        else
                        {
                            <div>@OnGetDisplayText(item)</div>
                        }
                    </li>
                }
            }
            else
            {
                <li class="dropdown-item">@NoDataTip</li>
            }
        </ul>
    </div>
</div>
<CascadingValue Value="this" IsFixed="true">
    @ChildContent
</CascadingValue>
